package com.frxuexi.lib_base.net

import com.frxuexi.lib_base.entity.BillBean
import com.frxuexi.lib_base.entity.BillBeanItem
import com.frxuexi.lib_base.entity.DepartBean
import com.frxuexi.lib_base.entity.EmpBean
import com.frxuexi.lib_base.entity.EmpBeanItem
import com.frxuexi.lib_base.entity.HourseBean
import com.frxuexi.lib_base.entity.HourseBeanItem
import com.frxuexi.lib_base.entity.MerchantBean
import com.frxuexi.lib_base.entity.MerchantBeanItem
import com.frxuexi.lib_base.entity.ParkBean
import com.frxuexi.lib_base.entity.ParkBeanItem
import com.frxuexi.lib_base.entity.PatrolTaskBean
import com.frxuexi.lib_base.entity.PatrolTaskBeanItem
import com.frxuexi.lib_base.entity.PayBean
import com.frxuexi.lib_base.entity.PayBeanItem
import com.frxuexi.lib_base.entity.PointBean
import com.frxuexi.lib_base.entity.PointBeanItem
import com.frxuexi.lib_base.entity.RepairBean
import com.frxuexi.lib_base.entity.RepairBeanItem
import com.frxuexi.lib_base.entity.Res
import com.frxuexi.lib_base.entity.SignBean
import com.frxuexi.lib_base.entity.SignBeanItem
import com.frxuexi.lib_base.entity.UserBean
import com.frxuexi.lib_base.entity.VisitBean
import com.frxuexi.lib_base.entity.VisitBeanItem
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {

    @POST("/api/user/login")
    suspend fun login(@Query("username")username:String,@Query("password")password:String):Res<UserBean>

    //车位
    @GET("/api/parking-spaces/type/{spaceType}")
    suspend fun getParksByType(@Path("spaceType")spaceType:String):Res<ParkBean>

    @GET("/api/parking-spaces/status/{spaceStatus}")
    suspend fun getParksByStatus(@Path("spaceStatus")spaceStatus:String):Res<ParkBean>

    @GET("/api/parking-spaces/area/{areaId}")
    suspend fun getParksByAreaId(@Path("areaId")areaId:Int):Res<ParkBean>

    @POST("/api/parking-spaces")
    suspend fun addPark(@Body body: RequestBody):Res<ParkBeanItem>

    @PUT("/api/parking-spaces/{id}")
    suspend fun editPark(@Path("id")id:Int,@Body body: RequestBody):Res<ParkBeanItem>

    @GET("/api/parking-spaces/user/{userId}")
    suspend fun getParkByUid(@Path("userId")userId:Int):Res<ParkBeanItem>

    //维修
    @GET("/api/repair-orders")
    suspend fun getRepairs():Res<RepairBean>

    @GET("/api/repair-orders/search")
    suspend fun getRepairsByUname(@Query("repairName")repairName:String):Res<RepairBean>

    @GET("/api/repair-orders/order-number/{orderNumber}")
    suspend fun getRepairByNo(@Path("orderNumber")orderNumber:String):Res<RepairBeanItem>

    @GET("/api/repair-orders/{id}")
    suspend fun getRepairById(@Path("id")id:Int):Res<RepairBeanItem>

    @PUT("/api/repair-orders/{id}")
    suspend fun updateRepair(@Path("id")id:Int,@Body body: RequestBody):Res<RepairBeanItem>

    @POST("/api/repair-orders")
    suspend fun addRepair(@Body body: RequestBody):Res<RepairBeanItem>

    @DELETE("/api/repair-orders/{id}")
    suspend fun deleteRepair(@Path("id")id:Int):Res<String>

    //来访
    @GET("/api/visit-appointments")
    suspend fun getVisits():Res<VisitBean>

    @GET("/api/visit-appointments/status/{status}")
    suspend fun getVisitByStatus(@Path("status")status:String):Res<VisitBean>

    @GET("/api/visit-appointments/{id}")
    suspend fun getVisitById(@Path("id")id:Int):Res<VisitBeanItem>

    @PATCH("/api/visit-appointments/approve/{id}")
    suspend fun approveVisit(@Path("id")id:Int):Res<VisitBeanItem>

    @PATCH("/api/visit-appointments/reject/{id}")
    suspend fun rejectVisit(@Path("id")id:Int):Res<VisitBeanItem>

    @DELETE("/api/visit-appointments/{id}")
    suspend fun deleteVisit(@Path("id")id:Int):Res<Boolean>

    @POST("/api/visit-appointments")
    suspend fun addVisit(@Body body: RequestBody):Res<VisitBeanItem>

    //考勤
    @GET("/api/attendances/user/{userId}")
    suspend fun getSigns(@Path("userId")userId:Int):Res<SignBean>

    @POST("/api/attendances")
    suspend fun sign(@Body body: RequestBody):Res<SignBeanItem>

    //人员
    @GET("/api/employees")
    suspend fun getEmps():Res<EmpBean>

    @GET("/api/departments")
    suspend fun getDeparts():Res<DepartBean>

    @POST("/api/employees")
    suspend fun addEmp(@Body body: RequestBody):Res<EmpBeanItem>

    //房源
    @GET("/api/properties")
    suspend fun getHourses():Res<HourseBean>

    @GET("/api/properties/region/{regionId}")
    suspend fun getHourseByRid(@Path("regionId")regionId:Int):Res<HourseBean>

    @PATCH("/api/properties/rent/{id}")
    suspend fun rent(@Path("id")id:Int,@Query("rentDate")rentDate:String):Res<HourseBeanItem>

    @PATCH("/api/properties/unrent/{id}")
    suspend fun unrent(@Path("id")id:Int):Res<HourseBeanItem>

    //商家入驻
    @GET("/api/merchant-applications")
    suspend fun getMerchants():Res<MerchantBean>

    @GET("/api/merchant-applications/{id}")
    suspend fun getMerchantById(@Path("id")id:Int):Res<MerchantBeanItem>

    @PATCH("/api/merchant-applications/approve/{id}")
    suspend fun approve(@Path("id")id:Int):Res<MerchantBeanItem>

    @PATCH("/api/merchant-applications/reject/{id}")
    suspend fun reject(@Path("id")id:Int):Res<MerchantBeanItem>

    @POST("/api/merchant-applications")
    suspend fun addMerchant(@Body body: RequestBody):Res<MerchantBeanItem>

    //点位
    @GET("/api/patrol-points")
    suspend fun getPoints():Res<PointBean>

    @GET("/api/patrol-points/search")
    suspend fun getPointsByType(@Query("location")location:String,@Query("name")name:String):Res<PointBean>

    @GET("/api/patrol-points/{id}")
    suspend fun getPointById(@Path("id")id:Int):Res<PointBeanItem>

    @GET("/api/patrol-tasks")
    suspend fun getPatrolTasks():Res<PatrolTaskBean>

    @GET("/api/patrol-tasks/by-status/{status}")
    suspend fun getPatrolTaskByStatus(@Path("status")status:String):Res<PatrolTaskBean>

    @GET("/api/patrol-tasks/{id}")
    suspend fun getTaskById(@Path("id")id:Int):Res<PatrolTaskBeanItem>

    //收银台
    @POST("/api/charge-items")
    suspend fun addPayProject(@Body body: RequestBody):Res<PayBeanItem>

    @GET("/api/charge-items/payer/{payerId}")
    suspend fun getPayProjectsByUid(@Path("payerId")payerId:Int):Res<PayBean>


    @PUT("/api/charge-items/{id}/payment")
    suspend fun payProject(@Path("id")id: Int,@Query("actualAmount")actualAmount:Int,
                           @Query("operator")operator:String,@Query("paymentMethod")paymentMethod:String,
                           @Query("paymentTime")paymentTime:String):Res<PayBeanItem>

    //账单
    @POST("/api/bills")
    suspend fun addBill(@Body body: RequestBody):Res<BillBeanItem>

    @GET("/api/bills/payer/{payerId}")
    suspend fun getMybills(@Path("payerId")payerId:Int):Res<BillBean>

    @GET("/api/bills/{id}")
    suspend fun getbillById(@Path("id")id:Int):Res<BillBeanItem>

}